#include <time.h>
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
    struct timeval begin;
    gettimeofday(&begin, NULL);
    sleep(4);

    struct timeval end;
    gettimeofday(&end, NULL);

    end.tv_sec -= begin.tv_sec;
    end.tv_usec -= begin.tv_usec;


    printf("Total time = %ds %dms\n", end.tv_sec, end.tv_usec / 1000);


    return 0;
}
